import { Component, OnInit } from '@angular/core';
import { UploadFileStatusEnum, MessageService } from '@iux/live';
import { result } from 'lodash';

@Component({
  selector: 'app-demo1',
  templateUrl: './demo1.component.html',
  styles: []
})
export class Demo1Component implements OnInit {

  constructor(private messageService: MessageService) { }

  ngOnInit() {
  }

  change(e) {
    if (e.action === UploadFileStatusEnum.ERROR) {
      e.files[0]['errorTip'] =  e.files[0].error.message || '自定义上传失败的原因';

      this.messageService.error(result(e, 'file.error.message') || '上传失败！');
    }
  }

}
